package com.uchengwang.ui.cm_ui.uu.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.uchengwang.R;
import com.uchengwang.ui.cm_ui.uu.bean.ChooseChatBean;
import com.zhy.autolayout.utils.AutoUtils;

import java.util.List;

/**
 * Created by U城网 on 2017/6/13.
 */

public class ChooseChatAdapter extends BaseAdapter{
    private Context context;
    private List<ChooseChatBean> list;

    public ChooseChatAdapter (Context context, List<ChooseChatBean> list){
        this.context = context;
        this.list = list;
    }


    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int i) {
        return list.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        ChooseVH vh = null;
        if (view ==null){
            vh = new ChooseVH();
            view = LayoutInflater.from(context).inflate(R.layout.item_choose_chat, null, false);

            vh.choose_text = (TextView) view.findViewById(R.id.choose_text);

            view.setTag(vh);
            AutoUtils.autoSize(view);
        }else {
            vh = (ChooseVH) view.getTag();
        }

        final ChooseChatBean bean = list.get(i);
        vh.choose_text.setText(bean.getTitle());
        if (bean.isCheck()){
            vh.choose_text.setBackgroundResource(R.drawable.school_lebal_yes);
            vh.choose_text.setTextColor(context.getResources().getColor(R.color.ucw_color));
        }else {
            vh.choose_text.setBackgroundResource(R.drawable.selector_ucity_item);
            vh.choose_text.setTextColor(context.getResources().getColor(R.color.ustudy_no_choose));
        }


        return view;
    }

    private class ChooseVH{
        private TextView choose_text;

    }
}
